﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Admin.Core.Common.Input;
using Admin.Core.Common.Output;
using Admin.Core.Common.ParamInput;
using Admin.Core.Service.Warehouse.XbcMeterrial;
using Admin.Core.Service.Warehouse.XbcMeterrial.Input;
using Admin.Core.Service.Warehouse.XbcMeterrial.Output;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Admin.Core.Controllers.Warehouse
{

    public class XbcMaterrialController : AreaController
    {
        private readonly IXbcMaterrialService _xbcMaterrialService;

        public XbcMaterrialController(IXbcMaterrialService xbcMaterrialService)
        {
            _xbcMaterrialService = xbcMaterrialService;
        }



        /// <summary>
        /// 查询单条库位信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _xbcMaterrialService.GetAsync(id);
        }


        /// <summary>
        /// 查询单条库位信息
        /// </summary>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<XbcMaterrialListOutput>> ExportAllPage(string name ,long? id)
        {
            return await _xbcMaterrialService.GetAllPageAsync(name, id);
        }



        /// <summary>
        /// 分页查询库位信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<XbcMaterrialFilterInput> model)
        {
            return await _xbcMaterrialService.PageAsync(model);
        }

      
        /// <summary>
        /// 新增库位
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(XbcMaterrialAddInput input)
        {
            return await _xbcMaterrialService.AddAsync(input);
        }

        /// <summary>
        /// 修改库位
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(XbMaterrialUpdateInput input)
        {
            return await _xbcMaterrialService.UpdateAsync(input);
        }


        /// <summary>
        /// 删除库位
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _xbcMaterrialService.SoftDeleteAsync(id);
        }

        /// <summary>
        /// 批量删除库位
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> BatchSoftDelete(long[] ids)
        {
            return await _xbcMaterrialService.BatchSoftDeleteAsync(ids);
        }

    }
}
